#!/bin/bash

flink=/opt/module/flink-1.13.1/bin/flink
jar=/opt/gmall0624/gmall-realtime-1.0-SNAPSHOT.jar

apps=(
com.atguigu.realtime.app.dwd.DwdLogApp
)

# 把正在运行的所有的job放入到数组中
running_apps=`${flink} list -r 2>/dev/null | awk '/RUNNING/ {print $(NF-1)}'`

for app in ${apps[*]} ; do
    app_name=`echo ${app} | awk -F . '{print $NF}'`
    if [[ "${running_apps[@]}" =~ ${app_name} ]]; then
        echo "$app_name 已经启动无序重复启动...."
    else
        echo "$app_name 开始启动...."
        ${flink} run -d -c $app $jar
    fi

done



